/*
 * gis_analytics_panels.css — Panel-specific & Phase 4 Analytics Styles
 * ──────────────────────────────────────────────────────────────────────────
 * What:    Styles for prediction drawer, closure panel, deployment impact,
 *          pin-drop marker, confidence badges, strategy badges, pipeline
 *          waterfall, and pass progress bar. Split from gis_analytics.css
 *          to respect the 800-line file size rule.
 * Depends: gis_analytics.css (shared classes), gis_atm-gis-design-system.css
 * ──────────────────────────────────────────────────────────────────────────
 */


/* =========================================================================
   PIN-DROP PREDICTION — Cursor override
   ========================================================================= */

#map.pin-drop-mode {
    cursor: crosshair !important;
}

#map.pin-drop-mode .leaflet-interactive {
    cursor: crosshair !important;
}


/* =========================================================================
   PIN MARKER — Pulsing drop indicator
   ========================================================================= */

.pin-marker-icon {
    background: transparent !important;
    border: none !important;
}

.pin-marker-pulse {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.85);
    border: 2px solid #3b82f6;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
    animation: pinPulse 1.6s ease-in-out infinite;
    position: relative;
}

.pin-marker-pulse::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.3);
    animation: pinPulseRing 1.6s ease-in-out infinite;
}

@keyframes pinPulse {
    0%   { box-shadow: 0 0 0 0   rgba(59, 130, 246, 0.5); }
    70%  { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0   rgba(59, 130, 246, 0); }
}

@keyframes pinPulseRing {
    0%   { opacity: 0.8; transform: scale(0.8); }
    100% { opacity: 0;   transform: scale(1.6); }
}


/* =========================================================================
   PREDICT FORM — Site configuration form inside drawer
   ========================================================================= */

.predict-form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.predict-form-label {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.predict-select {
    width: 100%;
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
}

.predict-select:hover,
.predict-select:focus {
    border-color: var(--hex-blue);
    outline: none;
}

.predict-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-transform: none;
    font-size: 12px;
}

.predict-checkbox {
    width: 13px;
    height: 13px;
    accent-color: var(--hex-blue);
    cursor: pointer;
    flex-shrink: 0;
}

.predict-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.btn-predict {
    flex: 1;
    padding: 8px 12px;
    background: var(--hex-blue, #3b82f6);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-predict:hover { opacity: 0.88; }
.btn-predict:active { transform: scale(0.97); }

.btn-simulate {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--hex-blue, #3b82f6);
    border-radius: 4px;
    color: var(--hex-blue, #3b82f6);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn-simulate:hover {
    background: rgba(59, 130, 246, 0.1);
}


/* =========================================================================
   PREDICT RESULT — Big number display
   ========================================================================= */

.predict-result-big {
    font-family: var(--font-mono);
    font-size: 42px;
    font-weight: 700;
    color: var(--hex-blue, #3b82f6);
    line-height: 1.1;
    text-align: center;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}

.predict-result-sub {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    margin-top: 2px;
}


/* =========================================================================
   MATURATION CHART — Chart.js container
   ========================================================================= */

.maturation-chart-container {
    width: 100%;
    height: 150px;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.maturation-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}


/* =========================================================================
   DEPLOYMENT IMPACT — Cannibalization list
   ========================================================================= */

.deployment-impact-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.impact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 11px;
}

.impact-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-light);
}

.impact-atm-id {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.impact-dist {
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.impact-vol {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 60px;
    text-align: right;
}

.impact-negative { color: var(--accent-red,   #ef4444); }
.impact-neutral  { color: var(--text-muted); }


/* =========================================================================
   PREDICT TOAST — Brief instruction notification
   ========================================================================= */

.predict-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 18px;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-main);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.25s, transform 0.25s;
    backdrop-filter: blur(10px);
}

.predict-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* =========================================================================
   CLOSURE SIMULATION PANEL — Floating bottom-center card
   ========================================================================= */

.closure-sim-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 460px;
    max-width: calc(100vw - 48px);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(239, 68, 68, 0.15);
    z-index: 9000;
    animation: analyticsFadeIn 0.25s ease;
    overflow: hidden;
}

.closure-sim-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(239, 68, 68, 0.07);
}

.closure-sim-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.2s;
}

.closure-sim-close:hover {
    color: var(--accent-red);
}

.closure-stat-row {
    display: flex;
    gap: 0;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.closure-stat-row .analytics-stat {
    flex: 1;
    text-align: center;
    padding: 0 4px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.closure-stat-row .analytics-stat:last-child {
    border-right: none;
}

.closure-atm-list {
    padding: 10px 16px 14px;
    max-height: 160px;
    overflow-y: auto;
}

.closure-atm-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-family: var(--font-ui);
    font-size: 12px;
}

.closure-atm-item:last-child {
    border-bottom: none;
}


/* =========================================================================
   INTERCHANGE HOTSPOTS — Layer legend
   ========================================================================= */

.interchange-legend {
    position: fixed;
    bottom: 80px;
    right: 16px;
    background: rgba(15, 23, 42, 0.90);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 7px;
    padding: 10px 14px;
    z-index: 8000;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    animation: analyticsFadeIn 0.2s ease;
    min-width: 140px;
}

.interchange-legend-bar {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #3b82f6, #8b5cf6, #ef4444);
    margin: 6px 0 4px;
}

.interchange-popup {
    font-family: var(--font-ui);
}


/* =========================================================================
   FLOW ARROW ANIMATION — Animated SVG dashes on closure polylines
   ========================================================================= */

@keyframes flowDash {
    to { stroke-dashoffset: -30; }
}


/* =========================================================================
   PHASE 4 — Confidence dot badge system
   Three tiers: high (observed), medium (estimated), low (fallback)
   ========================================================================= */

.confidence-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    cursor: help;
}

.confidence-dot::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
}

.confidence-dot:hover::after {
    opacity: 1;
}

.confidence-high {
    background: var(--accent-green, #10b981);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

.confidence-medium {
    background: var(--accent-orange, #f59e0b);
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.5);
}

.confidence-low {
    background: var(--accent-red, #ef4444);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}


/* =========================================================================
   PHASE 4 — Source tag (inline label for redistribution source)
   ========================================================================= */

.source-tag {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.source-tag-sub {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.source-tag-grav {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange, #f59e0b);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.source-tag-mixed {
    background: rgba(59, 130, 246, 0.12);
    color: var(--hex-blue, #3b82f6);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.source-tag-precomputed {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-dim, #94a3b8);
    border: 1px solid rgba(148, 163, 184, 0.25);
}


/* =========================================================================
   PHASE 4 — Competitor flag (red dot for competitor ATMs in lists)
   ========================================================================= */

.competitor-flag {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-red, #ef4444);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
    flex-shrink: 0;
}


/* =========================================================================
   PHASE 4 — Pass progress bar (substitution vs gravity split)
   ========================================================================= */

.pass-progress-wrapper {
    padding: 8px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pass-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.pass-progress-label {
    font-family: var(--font-mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.pass-progress-label-val {
    font-weight: 600;
}

.pass-progress-label-p1 .pass-progress-label-val { color: var(--accent-green, #10b981); }
.pass-progress-label-p2 .pass-progress-label-val { color: var(--accent-orange, #f59e0b); }

.pass-progress-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
}

.pass-bar-p1 {
    background: var(--accent-green, #10b981);
    transition: width 0.4s ease;
}

.pass-bar-p2 {
    background: var(--accent-orange, #f59e0b);
    transition: width 0.4s ease;
}


/* =========================================================================
   PHASE 4 — Strategy badge (hexagonal outline)
   ========================================================================= */

.strategy-badge {
    display: inline-block;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

.strategy-monopoly {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple, #8b5cf6);
}

.strategy-capture {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan, #06b6d4);
}

.strategy-dense {
    background: rgba(59, 130, 246, 0.15);
    color: var(--hex-blue, #3b82f6);
}

.strategy-mixed {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-dim, #94a3b8);
}


/* =========================================================================
   PHASE 4 — Pipeline waterfall (collapsible analytical trace)
   ========================================================================= */

.pipeline-waterfall {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 8px;
}

.pipeline-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
}

.pipeline-toggle:hover {
    color: var(--hex-blue);
}

.pipeline-toggle-icon {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 10px;
}

.pipeline-waterfall.open .pipeline-toggle-icon {
    transform: rotate(90deg);
}

.pipeline-steps {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 12px;
}

.pipeline-waterfall.open .pipeline-steps {
    max-height: 500px;
    padding: 0 12px 10px;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    position: relative;
}

.pipeline-step-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--panel-bg-solid, #020617);
    flex-shrink: 0;
    z-index: 1;
}

.pipeline-step.active .pipeline-step-marker {
    border-color: var(--accent-green, #10b981);
    background: rgba(16, 185, 129, 0.2);
}

.pipeline-step-label {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
}

.pipeline-step-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.pipeline-connector {
    position: absolute;
    left: 4px;
    top: 18px;
    bottom: -5px;
    width: 2px;
    background: rgba(255, 255, 255, 0.06);
}

.pipeline-step:last-child .pipeline-connector {
    display: none;
}


/* =========================================================================
   PHASE 4 — Cannibalization source badge
   ========================================================================= */

.cannib-source-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 500;
}

.cannib-source-observed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.cannib-source-default {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange, #f59e0b);
    border: 1px solid rgba(245, 158, 11, 0.25);
}


/* =========================================================================
   PHASE 4 — Greenfield / Infill badge
   ========================================================================= */

.greenfield-badge {
    display: inline-block;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

.greenfield-badge-new {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan, #06b6d4);
}

.greenfield-badge-infill {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple, #8b5cf6);
}


/* =========================================================================
   PHASE 4 — CI band display
   ========================================================================= */

.ci-band {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.ci-band-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    position: relative;
}

.ci-band-fill {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 2px;
    background: var(--hex-blue, #3b82f6);
    opacity: 0.4;
}

.ci-band-point {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hex-blue, #3b82f6);
    border: 2px solid var(--text-main);
}

.ci-band-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
    min-width: 30px;
}


/* =========================================================================
   PHASE 4 — Tiered scenario tabs (competitor closure best/likely/worst)
   ========================================================================= */

.tiered-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tiered-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.tiered-tab:hover {
    color: var(--text-muted);
}

.tiered-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--hex-blue);
}

.tiered-tab-best    { color: var(--accent-green) !important; }
.tiered-tab-likely  { color: var(--hex-blue) !important; }
.tiered-tab-worst   { color: var(--accent-red) !important; }

.tiered-content {
    display: none;
    padding: 12px 16px;
}

.tiered-content.active {
    display: block;
}


/* =========================================================================
   RESPONSIVE — Mobile overrides (≤480px)
   ========================================================================= */

@media (max-width: 480px) {
    /* Prediction drawer: full width on mobile */
    .analytics-drawer {
        width: 100vw !important;
        right: 0;
        border-radius: 0;
    }

    /* Closure panel: full width, no transform */
    .closure-sim-panel {
        width: calc(100vw - 16px);
        left: 8px;
        transform: none;
        bottom: 8px;
    }

    /* Pass progress bar labels: stack vertically */
    .pass-progress-labels {
        flex-direction: column;
        gap: 2px;
    }

    /* Stat rows: wrap if needed */
    .closure-stat-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    .closure-stat-row .analytics-stat {
        flex: 1 1 45%;
        min-width: 80px;
        border-right: none;
    }

    /* Strategy/greenfield badges: smaller */
    .strategy-badge,
    .greenfield-badge {
        font-size: 9px;
        padding: 1px 8px;
    }

    /* CI band: stack labels */
    .ci-band {
        flex-wrap: wrap;
    }

    /* Predict result: scale down */
    .predict-result-big {
        font-size: 32px;
    }
}
